package com.whsxt.common.timer;

import java.io.File;
import java.util.Date;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.whsxt.common.util.FileUpdateUtil;

import cn.hutool.core.date.DateUtil;

@Component
public class TimerUtil {
	/**
	 * 指定每天的0点0分0秒清除_temp文件
	 */
	@Scheduled(cron = "58 59 23 * * ? ")
	public void deleteEndWithTemp() {
		System.out.println("1111");
		String date = DateUtil.format(new Date(), "yyyy-MM-dd");
		File file = new File(FileUpdateUtil.diskPath, date);
		if(file.exists()) {
			File[] listFiles = file.listFiles();
			for (File file2 : listFiles) {
				if(file2.toString().endsWith("_temp")) {
					System.out.println(file2.toString());
					file2.delete();
				}
			}
		}
	}
}
